﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using DevExpress.Xpo;
using Zero.Core.Domain;
using Zero.Core.Domain.Query;
using Zero.DataLayer.Donnees.Tarifs;
using Zero.POCO.Compagne;

namespace Zero.DataLayer.Repository
{
    public class TarifPrRepository : IRepository<TarifPr, Guid>
    {
        public TarifPr FindBy(Guid id)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<TarifPr> FindAll()
        {
            var list = new List<TarifPr>();

            var config = new AppSettingsReader();
            using (
               var uow = new UnitOfWork()
               {
                   ConnectionString =
                       ((string)config.GetValue("connect", typeof(string)))
               })
            {
                var TarifPrs = new XPCollection<XpoTarifPr>(uow);
                list.AddRange(TarifPrs.Select(MAP.MapInverse.MapTarifPresse));
            }
            return list;
        }

        public IEnumerable<TarifPr> FindBy(Query query)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<TarifPr> FindBy(Query query, int index, int count)
        {
            throw new NotImplementedException();
        }

        public void SaveAll(IEnumerable<TarifPr> entities)
        {
            throw new NotImplementedException();
        }

        public List<TarifPr> FindAll(List<Query> entities)
        {
            throw new NotImplementedException();
        }

        public void Save(TarifPr entity)
        {

            var config = new AppSettingsReader();
            using (
                  var uow = new UnitOfWork()
                  {
                      ConnectionString =
                          ((string)config.GetValue("connect", typeof(string)))
                  })
            {
                var comp = MAP.Map.MapTarifPr(entity, uow);
                uow.CommitChanges();
            }
        }

        public void Add(TarifPr entity)
        {
            throw new NotImplementedException();
        }

        public void Remove(TarifPr entity)
        {
            throw new NotImplementedException();
        }
    }
}